Skip to content

Two-phase site building with a new skill to convert html blocks to core Gutenberg blocks#3016

Open
epeicher wants to merge 9 commits intotrunkfrom
stu-1439-extract-html-blocks-generation-skill
Open

Two-phase site building with a new skill to convert html blocks to core Gutenberg blocks#3016
epeicher wants to merge 9 commits intotrunkfrom
stu-1439-extract-html-blocks-generation-skill

Conversation

@epeicher
Copy link
Copy Markdown
Contributor

@epeicher epeicher commented Apr 8, 2026

Related issues

How AI was used in this PR

Claude was used to implement the two-phase workflow, create the blockify skill, update the system prompt, and remove the deterministic HTML block checker. All code was reviewed, iterated on, and tested by the author.

Proposed Changes

  • New blockify skill (apps/cli/ai/plugin/skills/blockify/SKILL.md): A dedicated, user-invokable skill that handles the full block conversion workflow — reads back all content (posts + template parts), plans conversion element-by-element, rewrites with native blocks, validates markup, and does a final visual check. Includes block pattern reference, conversion mapping table, and explicit rules to prevent over-conservative skipping (e.g., always decompose sections rather than keeping them entirely as core/html).
  • Updated system prompt (apps/cli/ai/system-prompt.ts): Restructured workflow from 6 mixed steps to a two-phase approach. Phase 1 focuses on design, Phase 2 invokes the blockify skill. Block content guidelines restored from trunk as lightweight reference.

Testing Instructions

  • Apply this changes and run npm run cli:build and node apps/cli/dist/cli/main.mjs ai
  • Build a site with a prompt that a user would add, focused on the website and potential styles, but not necessarily specifying technical details like (Gutenberg blocks), an example prompt could be "Build a one page site for a luxury furniture brand called Mikado, known for its precision and high quality manufactoring. Use simple Icons for company logos that are clients (Nasa, SpaceX, Uber, Visa, Grab, bose, Discover, dji, Nikon, craftsman, sony). Use light colors", but I encourage you to use a different one.
  • Verify that the generated site uses Gutenberg blocks instead of core/html wrappers. For that, you can open <site-domain>/wp-admin/site-editor.php, click on the page and check the Document overview
CleanShot 2026-04-08 at 18 51 38@2x Additionally, you can try to edit any of the sections and check if you can update the text.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Introduces a deterministic check_html_blocks tool that parses block content
via wp.blocks.parse() in a real browser, identifies core/html blocks wrapping
structural HTML (divs, sections, headings, etc.), and flags them with
replacement suggestions. The check is also integrated into validate_blocks
so both validations run in a single call. Updates the system prompt with
detailed block pattern references and stricter guidelines.
@epeicher epeicher self-assigned this Apr 8, 2026
Keeps trunk's refactoring (separate remote/local content guidelines)
while applying the HTML block checker's enhanced block patterns and
stricter guidelines to LOCAL_CONTENT_GUIDELINES.
@epeicher epeicher marked this pull request as draft April 8, 2026 16:59
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 8, 2026

📊 Performance Test Results

Comparing 13d4925 vs trunk

app-size

Metric trunk 13d4925 Diff Change
App Size (Mac) 1285.76 MB 1266.84 MB 18.92 MB 🟢 -1.5%

site-editor

Metric trunk 13d4925 Diff Change
load 2003 ms 1871 ms 132 ms 🟢 -6.6%

site-startup

Metric trunk 13d4925 Diff Change
siteCreation 8105 ms 8125 ms +20 ms ⚪ 0.0%
siteStartup 4289 ms 4029 ms 260 ms 🟢 -6.1%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)


1. **Get site details**: Use site_info to get the site path, URL, and credentials.
2. **Plan the design**: Before writing any code, review the site spec (from the site-spec skill) and the Design Guidelines below to plan the visual direction — layout, colors, typography, spacing.
2. **Plan the design and block structure**: Before writing any code, review the site spec (from the site-spec skill) and the Design Guidelines below to plan the visual direction — layout, colors, typography, spacing. Also plan how each section maps to Gutenberg blocks: which sections use \`core/group\`, where to use \`core/columns\`, which text is \`core/heading\` vs \`core/paragraph\`, etc. Refer to the Block Content Guidelines for the correct markup patterns. Do NOT default to \`core/html\` — compose in native blocks from the start.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I don't like much is the coupling of the system prompt to the core blocks. Aren't the validation changes sufficient.

I'm also wondering why you used a single tool for both kind of validation (block validation and html blocks) instead of using separate tools. I'm not opinionated here as long as the solution works though.

Copy link
Copy Markdown
Contributor Author

@epeicher epeicher Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely a concern I have too, shared here also. The underlying problem seems to be that the agent tends to use html blocks all the time. Also in this comment I explain the issue I found with using only the tool.

I am going to experiment using external skills as an alternative or a more generic hint that doesn't couple that much with block implementations

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also wondering why you used a single tool for both kind of validation (block validation and html blocks) instead of using separate tools. I'm not opinionated here as long as the solution works though.

This was updated because during testing the AI agent reliably called validate_blocks on every piece of block content but consistently forgot to call check_html_blocks as a separate step

- \`<form>\` elements and interactive inputs
- Animation/interaction markup with no block equivalent (marquee, cursor)
- A single \`<script>\` block at the bottom of the page for JS
**CRITICAL — Think in blocks, not HTML.** When writing page/post content or template parts, you MUST compose content using Gutenberg block markup from the start. Do NOT write raw HTML sections and wrap them in \`<!-- wp:html -->\`. Instead, use the block patterns below to build every section.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you find that the changes to the system prompt here are necessary? Can't we just rely on the tool for validation and the agent should be capable to fix things properly based on the errors thrown by the tool (like we do for regular block validation).

Copy link
Copy Markdown
Contributor Author

@epeicher epeicher Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my initial approach and didn't work well, the agent was in a loop that took around 45 minutes where:

  • Initially created mainly html blocks
  • Used the tool to replace the html blocks by other core blocks
  • Refined the design and replaced the core blocks by html blocks
  • Validated again using the tool and replacing back to core blocks

The final result included a mixture of Groups and html blocks nested. I recorded a video with that first approach, you can skip to the relevant parts and see the loop 3ae9e-pb, for example on the minute 7:20 the agent had validated al the html blocks to use core blocks but it continues until minute 46 to complete the site.

Then I changed the system prompt to emphasize as much as possible using blocks, that improved the usage of blocks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but doesn't this mean that the validation tool is now unnecessary (so basically your skill suggestion)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a bit redundant now, but I found that the agent still uses it and updates some blocks. I am going to continue testing, and if I don't find that the tool helps, I will remove it

@youknowriad
Copy link
Copy Markdown
Contributor

One idea @mtias brings up all the time as well, is that maybe instead of asking our system prompt to generate the design in one step, we should split it into two steps: First generate the design in raw HTML + CSS, Second convert the HTML into blocks.

@epeicher
Copy link
Copy Markdown
Contributor Author

epeicher commented Apr 9, 2026

One idea @mtias brings up all the time as well, is that maybe instead of asking our system prompt to generate the design in one step, we should split it into two steps: First generate the design in raw HTML + CSS, Second convert the HTML into blocks.

I like that approach, as I had success in converting one of the testing sites from html to core blocks in a different session. I am going to iterate over that 👍

@mtias
Copy link
Copy Markdown
Member

mtias commented Apr 9, 2026

Yeah, two clean stages is worth a shot because there are various flows in which design > html+css is more straightforward for the model than design > blocks.

  1. Two-pass workflow in the system prompt — Explicitly split site building into "design pass" (HTML/CSS is fine, get the visuals right) and "block conversion pass" (convert everything to core blocks, validate). Right now the prompt mixes both concerns and the agent often stops after the design looks good.
  2. Validation gate — The validate_blocks tool exists but the agent treats it as optional. We can make the system prompt stricter: "After writing any template or page content, you MUST run validate_blocks. If any core/html blocks are found that could be core blocks, convert them before proceeding."
  3. A post-build audit step — Similar to how /classic-to-blocks is meant to work as a dedicated conversion pass, we could add an automatic "blockify" step at the end of every site build. The system prompt would say: "After building the site and taking screenshots, run a final block audit: list all core/html blocks and convert each one to the appropriate core block equivalent."

epeicher added 6 commits April 9, 2026 14:54
…sion

Replace the single-pass workflow that mixed design and block concerns with
two explicit phases. Phase 1 focuses on visual design with free HTML/CSS,
Phase 2 converts content to native Gutenberg blocks with validation.
Remove check_html_blocks tool and its integration in validate_blocks.
Phase 2 now relies on the agent self-identifying and converting HTML
blocks based on the block content guidelines, matching the natural
workflow observed in testing sessions. validate_blocks is kept for
block markup validation only.
The html-block-checker.ts module and its test file are no longer
referenced after switching to prompt-driven block conversion.
Move the Phase 2 block conversion logic and block content guidelines
from the system prompt into a dedicated blockify skill. The system
prompt now invokes the skill, keeping Phase 1 focused on design.
Add decomposition rules to prevent skipping entire sections when only
some sub-elements need core/html. Clarify that id, inline em/strong,
and loading attributes are not valid reasons to keep sections as HTML.
Restore LOCAL_CONTENT_GUIDELINES from trunk to the system prompt.
@epeicher epeicher changed the title Add HTML block checker to enforce native Gutenberg blocks Two-phase site building with blockify skill for native Gutenberg blocks Apr 10, 2026
@epeicher
Copy link
Copy Markdown
Contributor Author

@mtias, @youknowriad, I have applied the suggestion here of a two-pass approach and it works great.

I have created the following site https://rarandalopez-mxqjv-studio.wp.build/ with the following prompt:

Build a one page site for a luxury furtniture brand called "Auran Blocks 6", known for its precision and high quality manufactoring. Use elegant icons for company logos that are clients (Nasa, SpaceX, Uber, Visa, Grab, bose, Discover, dji, Nikon, craftsman, sony). Use light colors

and the result looks nice, and most of the components are editable

CleanShot 2026-04-10 at 18 00 12@2x

I have created an external skill that I reference from the system prompt, and I have also tested it stand-alone by converting another previously created site with a "Can you blockify this?" prompt. This also worked great.

Please let me know your view on the changes

@epeicher epeicher marked this pull request as ready for review April 10, 2026 16:18
@epeicher epeicher requested a review from a team April 10, 2026 16:18
@epeicher epeicher changed the title Two-phase site building with blockify skill for native Gutenberg blocks Two-phase site building with a new skill to convert html blocks to core Gutenberg blocks Apr 10, 2026
@chubes4
Copy link
Copy Markdown

chubes4 commented Apr 10, 2026

Ideally, this is something that could be handled server-side without needing an AI skill, which will burn more tokens.

See: WordPress/gutenberg#13163

If we defined core block transforms in PHP, then the agent could simply provide HTML while Gutenberg handles the conversion internally.

Similar to the client-side block conversion that already exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants